package b1.project.common.config;


import b1.project.common.base.BaseEntity;
import com.mybatisflex.annotation.InsertListener;

/**
 * 新增数据时候的默认赋值
 *
 * @author sun
 * @date 2024/9/27 23:31
 */
public class MyInsertListener implements InsertListener {
    @Override
    public void onInsert(Object entity) {
        String userId;
        String userName;
        // 获取扩展参数
        try {
//            userId = StpUtil.getExtra("userId").toString();
//            userName = StpUtil.getExtra("userName").toString();
        } catch (Exception e) {
            userId = "";
            userName = "";
        }

        BaseEntity baseEntity = (BaseEntity) entity;

        //设置  被新增时的一些默认数据
        baseEntity.setCreateById("");
        baseEntity.setCreateByName("");

    }
}
